package work.sajor.wechatpush.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import work.sajor.wechatpush.service.Pusher;

/**
 * 设置定时推送
 * @Author htl
 * @Date 2022/10/2 16:00
 */
@Component
public class JobWorker {

    // 要推送的用户openid
    @Value("${target.openId}")
    private String openId;

    // 推送服务
    @Autowired
    public Pusher pusherService;

    // 每天8:00触发，可以按照自己情况修改
    @Scheduled(cron = "0 0 8 * * ?")
//    @Scheduled(cron = "0 0/2 * * * ?")
    public void goodMorning(){
        System.err.println("消息已经推送----------------------------------------");
        pusherService.push(openId);
    }

}
